<?php
class Cl_UserPoint extends WdkClass 
{
	protected
		/******************************************************/
		//	원본 테이블 정보
		/******************************************************/
		$user_point_seq			= 0		,	//	키값
		$fk_user_seq			= 0		,	//	사용자 참조키
		$user_point_amount		= 0		,	//	금액
		$user_point_memo		= ''	,	//	메모사항
		$user_point_insert_time	= 0		;	//	등록시간
		/******************************************************/
		//	추가 정보
		/******************************************************/
	
	/**
	 * 	
	 */
	function __construct()
	{
		parent::__construct();
		self::getDbo();
	}
	
	/**
	 *	
	 */
	public function __init($data)
	{
		parent::__init($data);
		self::dformat();
	}
	
	/**
	 *	
	 */
	public function load($user_point_seq)
	{
		/*------------------------------------------------------------*/
		$dbo = self::getDbo();
		/*------------------------------------------------------------*/
		self::__init($dbo->cLoad($user_point_seq));
	}
	
	/**
	 *	
	 */
	public function dformat()
	{
	
	}
	
	/**
	 * 
	 */
	public function autoUpdate($log='')
	{
		if((int)$this->user_point_seq > 0)
		{
			$this->update($log);
		}
		else
		{
			$this->insert($log);
		}
	}
	
	/**
	 *	
	 */
	public function insert($log='Insert')
	{
		/*------------------------------------------------------------*/
		$dbo = self::getDbo();
		/*------------------------------------------------------------*/
		$this->user_point_insert_time	= time();
		
		$data = array(	'fk_user_seq'				=>	$this->fk_user_seq,
						'user_point_amount'			=>	$this->user_point_amount,
						'user_point_memo'			=>	$this->user_point_memo,
						'user_point_insert_time'	=>	$this->user_point_insert_time
					);
		$this->user_point_seq = $dbo->insert($data);
		$this->backup($log);
	}
	
	/**
	 * 
	 */
	public function update($log='update')
	{
		/*------------------------------------------------------------*/
		$dbo = self::getDbo();
		/*------------------------------------------------------------*/

		
		$data = array(	'user_point_amount'			=>	$this->user_point_amount,
						'user_point_memo'			=>	$this->user_point_memo
					);
		$dbo->update($data, array("user_point_seq = ".$this->user_point_seq));
		$this->backup($log);
	}
	
	/**
	 * 
	 */
	public function delete($log='delete')
	{
		/*------------------------------------------------------------*/
		$dbo = self::getDbo();
		/*------------------------------------------------------------*/
		$dbo->pdelete(array("user_point_seq = ".$this->user_point_seq));
		$this->backup($log);
	}
	
	/**
	 *	
	 */
	private function backup($log='')
	{
// 		/*------------------------------------------------------------*/
// 		$dbo = self::getDbo();
// 		/*------------------------------------------------------------*/
// 		$dbo->log($this->user_seq, $log, $this->backup_data);
	}
	
	/**
	 * 
	 */
	public function getDbo()
	{
		return Wdk::model(substr(__CLASS__, 3));
	}
}